package com.example.admin.fragment;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;

import com.example.admin.R;
import com.example.admin.SQLite.SqLiteOpenHelper;
import com.example.admin.SQLite.User;
import com.example.admin.adapter.AdminUserdapter;

import java.util.ArrayList;

public class Tab0Fragment extends Fragment {
    AdminUserdapter userdapter;
    RecyclerView recyclerView;
    EditText s1, s2, s3;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_tab0, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        s1 = view.findViewById(R.id.s1);
        s2 = view.findViewById(R.id.s2);
        s3 = view.findViewById(R.id.s3);

        SqLiteOpenHelper dbHelper = new SqLiteOpenHelper(getActivity());
        ArrayList<User> list = dbHelper.getUserList();
        userdapter = new AdminUserdapter();
        recyclerView = view.findViewById(R.id.recyclerView);
        recyclerView.setAdapter(userdapter);
        userdapter.setNewData(list);
        view.findViewById(R.id.tvCha).setOnClickListener(v -> {
            String s11 = s1.getText().toString().trim();
            String s21 = s2.getText().toString().trim();
            String s31 = s3.getText().toString().trim();


        });
    }
}